Skip to content

fix(toolkit-lib): run cdk gc's S3 tag calls concurrently - #2166

Open
dveldhoen wants to merge 1 commit into
aws:mainfrom
dveldhoen:fix/gc-concurrent-s3-tagging
Open

dveldhoen wants to merge 1 commit into
aws:mainfrom
dveldhoen:fix/gc-concurrent-s3-tagging

Conversation

@dveldhoen

@dveldhoen dveldhoen commented Nov 17, 2026 •

Copy link
Copy Markdown

Part of #2165.

parallelReadAllTags, parallelTagS3 and parallelUntagS3 awaited each call inside their loop, so the pLimit(50) limiter only ever had one call in flight. On a bootstrap bucket with tens of thousands of objects, cdk gc took hours. They now run through the existing parallelPromises helper with the same limit of 50. parallelUntagS3 still runs its calls for each object in order.

On failure, parallelPromises stops starting new per-object tasks after the first error and waits for the running ones to finish before it rejects, so nothing is still running when garbageCollect() fails.

The new unit test counts how many tag reads, untags and writes are in flight at once, and expects 50 for each. It fails without this change (1 instead of 50).

I left the ECR loops (parallelTagEcr, parallelUntagEcr) as they are, to keep this PR to the S3 path that I measured. ECR's API rate quotas are lower than S3's, so running those calls concurrently deserves its own look.

Measured on a bucket of about 24,400 objects: a local --action=print scan of the whole bucket plus its ECR repository, with an equivalent of this change and #2167 (keep-alive for the CLI's HTTPS agent) applied as a local patch, finished in 137 seconds. Before, a run in CI got through about 2,000 objects in 30 minutes. With only the concurrency part of that patch, a local run ended with ECONNRESET after about 4,000 objects.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

parallelReadAllTags, parallelTagS3 and parallelUntagS3 awaited each call inside their loop, so the p-limit limiter only ever had one call in flight. Run them through parallelPromises with the same limit of 50.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.55%. Comparing base (9f41f76) to head (2d45483).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2166   +/-   ##
=======================================
  Coverage   92.55%   92.55%           
=======================================
  Files          81       81           
  Lines       13224    13224           
  Branches     1915     1915           
=======================================
  Hits        12239    12239           
  Misses        947      947           
  Partials       38       38           
Flag Coverage Δ
suite.unit 92.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch is waiting to be deployed

1 inactive and 1 waiting deployments
integ-approval — 2d454837 Waiting Nov 17, 2026 by dveldhoen via prepare #7754
automation — 2d454837 Deployed Nov 17, 2026 by dveldhoen via Set AutoQueue on PR #2166 #4019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants